package com.zmn.oms.services.impl.outermap;

import com.zmn.oms.model.entity.outermap.OrderOuterMap;
import com.zmn.oms.model.entity.outermap.OrderOuterMapQuery;
import com.zmn.oms.persistence.interfaces.outermap.OrderOuterMapDao;
import com.zmn.oms.services.interfaces.outermap.OrderOuterMapService;
import io.shardingsphere.api.HintManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 类描述：外部订单ID关系
 *
 * @author liuying
 * @date 2019/03/22 16:19
 */
@Service
public class OrderOuterMapServiceImpl implements OrderOuterMapService {

    @Autowired
    private OrderOuterMapDao orderOuterMapDao;

    @Override
    public OrderOuterMap findByOuterId(OrderOuterMapQuery orderOuterMapQuery) {
        try (HintManager hintManager = HintManager.getInstance()) {
            hintManager.setMasterRouteOnly();
            return orderOuterMapDao.findByOuterId(orderOuterMapQuery);
        }
    }

    @Override
    public void insertOuterMap(OrderOuterMap orderOuterMap) {
        orderOuterMapDao.insert(orderOuterMap);
    }
}
